#include "h_stm32_hal_timer.h"

#include "h_stm32_hal_defines.h"

//////////////////////////////////////////////////////////////////////////////////
#define h_stm32_hal_delay_timer                     htim17
extern TIM_HandleTypeDef                            htim17;
//////////////////////////////////////////////////////////////////////////////////

void delay_us(unsigned int dly)
{
    __HAL_TIM_SET_COUNTER(&h_stm32_hal_delay_timer, 0);
    __HAL_TIM_ENABLE(&h_stm32_hal_delay_timer);
    while(__HAL_TIM_GET_COUNTER(&h_stm32_hal_delay_timer) < (48 * dly));    //48Mhz
     // Disable the Peripheral
    __HAL_TIM_DISABLE(&h_stm32_hal_delay_timer);
}

void delay_ms(unsigned int dly)
{
    unsigned int i = 0U;
    while(i++ < dly) {
        delay_us(1000);
    }
}